home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / CONVR403.ZIP;1 / CONVERT.DOC < prev    next >
Encoding:
Text File  |  1994-03-20  |  18.7 KB  |  395 lines

  1. CONVERT.DOC
  2. 02/01/94
  3.  
  4. The CONVERT.EXE program converts data between several basic data formats.
  5. Features:
  6.  
  7.   * You can read data in from any of the following data formats:
  8.       ASCII-delimited
  9.       fixed field
  10.       dBase-compatible
  11.   * You can write data out in any of the following data formats:
  12.       ASCII-delimited
  13.       fixed field
  14.       dBase-compatible
  15.       WKS (Lotus 1-2-3 release 1 compatible)
  16.   * For ASCII-delimited files, you can specify the delimiters used between
  17.     fields as well as around numeric or character data
  18.   * For dBase input files, you can retain deleted records if you want
  19.   * You can resize variables or drop them entirely if desired
  20.   * You can specify up to 10 include filters; all records processed must meet
  21.     at least one of these filter conditions
  22.   * You can specify up to 10 exclude filters; any records which meet these
  23.     filter conditions are dropped
  24.   * For WKS output files, you can process input files bigger than Lotus
  25.     1-2-3 itself can handle (1-2-3 limits input records to being 240 characters
  26.     or less
  27.  
  28.  
  29. Program written by:
  30.                         Bruce Guthrie
  31.                         Room H-4885
  32.                         U.S. Dept of Commerce/ESA/OBA/BSISD
  33.                         Washington, D.C. 20230
  34.  
  35.                         (202) 482-3234
  36.  
  37. You may freely copy and re-distribute this program; however, the U.S.
  38. Department of Commerce neither guarantees nor assures compatibility of the
  39. program with all computer software or hardware.
  40.  
  41. Foreign users:  Please provide an Internet address in all correspondence or
  42. and just e-mail your problems to me at bgu@cu.nih.gov
  43.  
  44.  
  45.  
  46. Data format types:
  47.  
  48. An ASCII-delimited file is one which typically has double quotes around each
  49. character field (the quotes are optional in CONVERT) and typically commas
  50. between fields.  Leading and trailing spaces are removed from character as well
  51. as all other values.
  52.  
  53. A fixed-field file places each field in the same column positions on each
  54. record.  The lengths of the fields are the same from record to record.
  55.  
  56. As an example, these might be an ASCII-delimited records:
  57.  
  58.         "Economic Bulletin Board","202 482-3870",35
  59.         "EBB High-Speed","202 482-2584",100
  60.  
  61. Fixed-field file records might look like this for the same data:
  62.  
  63.         Economic Bulletin Board 202 482-3870  35
  64.         EBB High-Speed          202 482-2584 100
  65.  
  66. WKS files are supported directly by Lotus 1-2-3 (all versions) as well as most
  67. other spreadsheet programs.  DBF files are supported by dBaseIII, dBaseIII+,
  68. dBaseIV, and most other data base management programs (Paradox etc).
  69.  
  70.  
  71.  
  72. Field definition file:
  73.  
  74. Unless you are reading a dBase file, this program requires a field definition
  75. file to figure out the characteristics for each field and also to set certain
  76. file characteristics.  If you're processing an ASCII-delimited input file, the
  77. routine can try to create a field definition file for you if desired.
  78.  
  79. The definition file can be created with any text editor.  The definition file
  80. consists of several records with the following fields separated by spaces.
  81. Except for the record type indicator (which must begin in column 1), all other
  82. fields can be placed in any columns:
  83.  
  84.         (1) record type (see below)
  85.         (2) length of field on input
  86.         (3) number of decimal places for numeric data (if you don't know,
  87.             put a "?" here; for non-numeric data, a "0" is fine) on output
  88.         (4) length of field on output
  89.  
  90. Any characters after the field length are treated as comment fields.  You would
  91. typically use this to enter the field name or column position or any other
  92. information of use to you.
  93.  
  94. The data record types accepted by this routine are as follows:
  95.  
  96.         type C = character data
  97.              N = numeric
  98.              L = logical (T or F)
  99.              D = date (in yyyymmdd format)
  100.  
  101. The data fields should be in the order the fields are found in the source file.
  102.  
  103. You may also specify up to 10 include filters and up to 10 exclude filters in
  104. the field definition file.  If an include filter is specified, the input record
  105. must contain at least one of the specified character strings in order to be
  106. processed.  If an exclude filter is specified, any input record which contains
  107. any of the specified character strings will be ignored.  Filters are case
  108. sensitive (capitalization matters) and processed as "or" items (if any filter is
  109. met, the condition is met; filters are not combined to determine fulfillment).
  110. The filters are specified in the field definition file in the following ways:
  111.  
  112.         /+=string     include filter, the string "string" can appear anywhere
  113.         /S+=string    include filter, the string "string" is at the beginning
  114.                       of the record
  115.         /+S=string    include filter, the string "string" is at the end of the
  116.                       record
  117.         /-=string     exclude filter, the string "string" can appear anywhere
  118.         /S-=string    exclude filter, the string "string" is at the beginning
  119.                       of the record
  120.         /-S=string    exclude filter, the string "string" is at the end of the
  121.                       record
  122.  
  123.  
  124. For example, if you want to specify in your control file that you only want
  125. records that contain either "Japan" or "France" *and* you want to exclude any
  126. records that begin with an underscore character, you would need to include the
  127. following three filter statements:
  128.  
  129.         /+=Japan
  130.         /+=France
  131.         /S-=_
  132.  
  133. The character string can include hexadecimal codes (in the &Hxx format) or
  134. decimal codes (in the \ddd format) if necessary.
  135.  
  136. Note that for fixed field files, you have to account for every byte in the file.
  137. If you have something like this:
  138.  
  139.         12345678_1_2345678_2_2345678_3      (column positions)
  140.         APPLE    X Y    12 BANANAS
  141.  
  142. Even though you may think you only have five fields, the following .DEF file
  143. will NOT work:
  144.  
  145.         ; Bad .DEF file:  Note does not account for blank spaces
  146.         C   8 0   8 Fruit1
  147.         C   1 0   1 Class1
  148.         C   1 0   1 Class2
  149.         N   5 0   5 Value
  150.         C  11 0  11 Fruit2
  151.  
  152. You may want the Fruit1 field to be in columns 1 through 8 and Class1 to be in
  153. column 10 but the routine will not know to skip column 9 so it will start
  154. reading Class1 beginning in column 9, Class2 beginning in column 10, etc.  To
  155. drop the blank positions, you have to add dummy fields on input and ask for them
  156. to be dropped on output:
  157.  
  158.         ; Good .DEF file:  Spaces between fields are accounted for
  159.         C   8 0   8 Fruit1
  160.         C   1 0   0 Filler
  161.         C   1 0   1 Class1
  162.         C   1 0   0 Filler
  163.         C   1 0   1 Class2
  164.         C   1 0   0 Filler
  165.         N   5 0   5 Value
  166.         C   1 0   0 Filler
  167.         C  11 0  11 Fruit2
  168.  
  169. You can also use the input field length and output field lengths to either drop
  170. fields using other formats (by specifying a zero length for the output field
  171. length) or for creating fields on output (by specifying a zero length for the
  172. input field length).  You can also use this to expand on contract a field.  For
  173. example, if Fruit1 is 8 characters long but you only want it to occupy 4
  174. characters on output (thus the field would be truncated), specify 8 for the
  175. input field length and 4 for the output field length.
  176.  
  177. For dBase files, a deffile will automatically be created for you unless you
  178. specify /DEF.  In that case, the routine will read the deffile and act
  179. appropriately.  This is necessary if you want fields expanded or ignored.
  180.  
  181.  
  182. Syntax:
  183.  
  184.     CONVERT infile [ outfile [ deffile ] ] [ [ /DEF=deffile ] [ /DEF | /-DEF ]
  185.       [ /OVERWRITE | /-OVERWRITE | /APPEND | /OVERASK ]
  186.       [ /FROM FIXED | /FROM ASCII | /FROM DBF ] [ /DELETED ]
  187.       [ /TO FIXED | /TO ASCII | /TO WKS | /TO DBF ] [ /HEADER | /-HEADER ]
  188.       [ /DELIMS=aroundstrings,aroundnums,betweenfields ] [ /BEEP | /-BEEP ]
  189.       [ /INMISS=val ] [ /INMISSC=val ] [ /OUTMISS=val ] [ /OUTMISSC=val ]
  190.       [ /SKIP | /MISSING | /ABORT ] [ /Q ] [ /? | /?&H ]
  191.  
  192. "infile" is the file specification for the ASCII-delimited or fixed-field file
  193. you want converted.  You can specify a drive and path specification if
  194. necessary.  This parameter is required.
  195.  
  196. "outfile" is the file specification of the file you want to create.  You can
  197. specify a drive and path specification if necessary.  If no outfile is provided,
  198. the routine will presume you want the output file called the same thing as the
  199. infile but you want the extension to be ".FIX" (if the output file is a
  200. fixed-field file), ".PRN" (if the output file is ASCII-delimited), or ".WKS" (if
  201. the output file is to be in a WKS format).
  202.  
  203. "deffile" is the file specification for the field definition file.  You can
  204. specify a drive and path specification if necessary.  If no deffile is
  205. specifically provided, the routine will presume it is called the same thing as
  206. the infile but it has the extension of ".DEF".  Note that the deffile can only
  207. be provided if you also specify the outfile name.
  208.  
  209. "/DEF=deffile" is the same thing as the "deffile" parm alone above but it's
  210. not position specific so you can leave out the output file name if desired.
  211.  
  212. "/DEF" applies to dBase input files only.  It tells CONVERT that you want to
  213. read the field information from an existing field-definition file instead of
  214. reading the definition in dBase itself.  Normally, this is only done if you want
  215. the program to expand, condense, or eliminate some fields.
  216.  
  217. "/-DEF" applies to ASCII-delimited input files only.  It tells CONVERT to scan
  218. the first few records in the input file and to figure out the field-definition
  219. file for you.  There are some risks in this primarily in that the routine may
  220. guess a field type incorrectly.  This also takes awhile.  The routine will
  221. automatically write out the field-definition file for you if you select this
  222. option.
  223.  
  224.  
  225. "/OVERWRITE" says to overwrite the output file if it exists already.
  226.  
  227. "/-OVERWRITE" says to abort if the output file exists already.
  228.  
  229. "/APPEND" says to append (add) to the output file if it exists already.  This
  230. option is only available if you're creating either a fixed-field or ASCII-
  231. delimited output file.
  232.  
  233. "/OVERASK" says to ask if the output file exists already.  This is typically
  234. the default but it's CONFIGWS-able.
  235.  
  236. "/FROM FIXED", "/FROM ASCII", and "/FROM DBF" specifies the format for the input
  237. file.  The routine will typically read the file and guess its format for you.
  238. You can also specify a default by using the CONFIGWS.EXE program.
  239.  
  240. "/DELETED" applies for dBase input files only.  It says you want to retain
  241. deleted records.  Otherwise, they're dropped in the output file.
  242.  
  243. "/TO FIXED", "/TO ASCII", "/TO WKS", and "/TO DBF" tells the routine what sort
  244. of output file you'd like to create.  Typically defaults to "/TO WKS" although
  245. you can change this using the CONFIGWS.EXE program.
  246.  
  247. "/HEADER" is used in conjunction with WKS output files.  If /HEADER is in
  248. effect, the first row of the spreadsheet will contain the variable name for the
  249. cell as provided in your control file.  If none are provided, the field names
  250. will be FIELD_01 onward.  /-HEADER turns this off and is the default.  Note that
  251. the header line (if any) will show up in the output counts.
  252.  
  253. "/DELIMS=aroundstrings,aroundnums,betweenfields" allows you to specify the
  254. delimiters (in sequence) around string fields, around numeric fields, and
  255. between fields.  Defaults to:
  256.  
  257.         /DELIMS=",,,
  258.  
  259. (Use quotes around character strings, nothing around numeric data, and the third
  260. comma indicates that there is a comma between fields.) The replacement string
  261. can include hexadecimal codes (in the &Hxx format) or decimal codes (in the \ddd
  262. format) if necessary so either of the following would put a tab between fields:
  263.  
  264.         /DELIMS=",,&H09
  265.         /DELIMS=",,\009
  266.  
  267. See the table of hexadecimal and decimal codes at the end of this documentation.
  268.  
  269.  
  270. "/BEEP" beeps when the program is finished.
  271.  
  272. "/-BEEP" reverses /BEEP.  This is normally the default but you can override this
  273. using the CONFIGWS.EXE program.
  274.  
  275. "/INMISS=val" specifies that any numeric value that has the character string
  276. representation of "val" will be considered missing.  Note that this is an exact
  277. character string comparison so /INMISS=1 will not compare to a value of "1.00".
  278. Defaults to /INMISS=NULL (which translates as spaces).
  279.  
  280. "/INMISSC=val" specifies that any character string value that has the value of
  281. "val" will be considered missing.  Defaults to /INMISSC= (which shouldn't
  282. happen very much).
  283.  
  284. "/OUTMISS=val" specifies that any missing numeric input value will be translated
  285. on output as "val".  For example, "/OUTMISS=N.A." would fill in "N.A." for each
  286. missing value.  Defaults to /OUTMISS=NULL (which translates as spaces).
  287.  
  288. "/OUTMISSC=val" specifies that any missing character input value will be
  289. translated on output as "val".  Defaults to /OUTMISSC=NULL (which translates as
  290. spaces).
  291.  
  292. "/SKIP" says to skip records with bad data values; otherwise the routine
  293. aborts when it runs into any.  /SKIP, /MISSING, and /ABORT are mutually
  294. exclusive.
  295.  
  296. "/MISSING" says to presume any missing fields in an ASCII-delimited record
  297. should be filled in with blanks (for character fields) and 0 for numeric fields.
  298. Incomplete records are written out (unlike in /SKIP).  /SKIP, /MISSING, and
  299. /ABORT are mutually exclusive.  Note that the program will only print out the
  300. first "bad" record.  There may be others that show up after this one.
  301.  
  302. "/ABORT" says to abort when you run into bad records.  This is typically the
  303. default but you can change this using the CONFIGWS.EXE program.  /SKIP,
  304. /MISSING, and /ABORT are mutually exclusive.
  305.  
  306. "/Q" turns off the line-by-line status report.
  307.  
  308. "/?" (or "/HELP" or "HELP" ) gives you the syntax for the command.
  309.  
  310. "/?&H" gives you a hexadecimal and decimal conversion table.
  311.  
  312.  
  313.  
  314. Return codes:
  315.  
  316. CONVERT returns the following ERRORLEVEL codes:
  317.         0 = no problems, file converted
  318.       254 = problems for formats of data
  319.       255 = syntax problems, file(s) not found, or /? requested
  320.  
  321.  
  322. Restrictions and Caveats:
  323.  
  324. The program cannot handle dBase files with Memo fields.
  325.  
  326. Most spreadsheet programs restrict a given field length to being 240 characters
  327. or less.
  328.  
  329. Date fields which are in the form "yy-mm-dd" (instead of "yyyymmdd") should be
  330. declared as character fields instead of date fields.
  331.  
  332. Date fields converted for WKS files are changed into strings of the "yy-mm-dd"
  333. format.
  334.  
  335.  
  336.  
  337. Decimal and hexadecimal codes:
  338.   e.g. "\066\097\116" and "&H426174" both are "Bat"
  339. +---------------------------------------------------------------------------
  340. | dec  hex chr | dec  hex chr | dec  hex chr | dec  hex chr | dec  hex chr |
  341. +--------------+--------------+--------------+--------------+--------------+
  342. | \000 &H00 nul| \052 &H34 4  | \104 &H68 h  | \156 &H9C ú  | \208 &HD0 –  |
  343. | \001 &H01   | \053 &H35 5  | \105 &H69 i  | \157 &H9D ù  | \209 &HD1 —  |
  344. | \002 &H02   | \054 &H36 6  | \106 &H6A j  | \158 &H9E û  | \210 &HD2 “  |
  345. | \003 &H03   | \055 &H37 7  | \107 &H6B k  | \159 &H9F ü  | \211 &HD3 ”  |
  346. | \004 &H04   | \056 &H38 8  | \108 &H6C l  | \160 &HA0 †  | \212 &HD4 ‘  |
  347. | \005 &H05   | \057 &H39 9  | \109 &H6D m  | \161 &HA1 °  | \213 &HD5 ’  |
  348. | \006 &H06   | \058 &H3A :  | \110 &H6E n  | \162 &HA2 ¢  | \214 &HD6 ÷  |
  349. | \007 &H07 bel| \059 &H3B ;  | \111 &H6F o  | \163 &HA3 £  | \215 &HD7 ◊  |
  350. | \008 &H08 bs | \060 &H3C <  | \112 &H70 p  | \164 &HA4 §  | \216 &HD8 ÿ  |
  351. | \009 &H09 tab| \061 &H3D =  | \113 &H71 q  | \165 &HA5 •  | \217 &HD9 Ÿ  |
  352. | \010 &H0A lf | \062 &H3E >  | \114 &H72 r  | \166 &HA6 ¶  | \218 &HDA ⁄  |
  353. | \011 &H0B vt | \063 &H3F ?  | \115 &H73 s  | \167 &HA7 ß  | \219 &HDB €  |
  354. | \012 &H0C pg | \064 &H40 @  | \116 &H74 t  | \168 &HA8 ®  | \220 &HDC ‹  |
  355. | \013 &H0D cr | \065 &H41 A  | \117 &H75 u  | \169 &HA9 ©  | \221 &HDD ›  |
  356. | \014 &H0E   | \066 &H42 B  | \118 &H76 v  | \170 &HAA ™  | \222 &HDE fi  |
  357. | \015 &H0F   | \067 &H43 C  | \119 &H77 w  | \171 &HAB ´  | \223 &HDF fl  |
  358. | \016 &H10   | \068 &H44 D  | \120 &H78 x  | \172 &HAC ¨  | \224 &HE0 ‡  |
  359. | \017 &H11   | \069 &H45 E  | \121 &H79 y  | \173 &HAD ≠  | \225 &HE1 ·  |
  360. | \018 &H12   | \070 &H46 F  | \122 &H7A z  | \174 &HAE Æ  | \226 &HE2 ‚  |
  361. | \019 &H13   | \071 &H47 G  | \123 &H7B {  | \175 &HAF Ø  | \227 &HE3 „  |
  362. | \020 &H14   | \072 &H48 H  | \124 &H7C |  | \176 &HB0 ∞  | \228 &HE4 ‰  |
  363. | \021 &H15   | \073 &H49 I  | \125 &H7D }  | \177 &HB1 ±  | \229 &HE5 Â  |
  364. | \022 &H16   | \074 &H4A J  | \126 &H7E ~  | \178 &HB2 ≤  | \230 &HE6 Ê  |
  365. | \023 &H17   | \075 &H4B K  | \127 &H7F   | \179 &HB3 ≥  | \231 &HE7 Á  |
  366. | \024 &H18   | \076 &H4C L  | \128 &H80 Ä  | \180 &HB4 ¥  | \232 &HE8 Ë  |
  367. | \025 &H19   | \077 &H4D M  | \129 &H81 Å  | \181 &HB5 µ  | \233 &HE9 È  |
  368. | \026 &H1A eof| \078 &H4E N  | \130 &H82 Ç  | \182 &HB6 ∂  | \234 &HEA Í  |
  369. | \027 &H1B esc| \079 &H4F O  | \131 &H83 É  | \183 &HB7 ∑  | \235 &HEB Î  |
  370. | \028 &H1C   | \080 &H50 P  | \132 &H84 Ñ  | \184 &HB8 ∏  | \236 &HEC Ï  |
  371. | \029 &H1D ???| \081 &H51 Q  | \133 &H85 Ö  | \185 &HB9 π  | \237 &HED Ì  |
  372. | \030 &H1E ???| \082 &H52 R  | \134 &H86 Ü  | \186 &HBA ∫  | \238 &HEE Ó  |
  373. | \031 &H1F ???| \083 &H53 S  | \135 &H87 á  | \187 &HBB ª  | \239 &HEF Ô  |
  374. | \032 &H20    | \084 &H54 T  | \136 &H88 à  | \188 &HBC º  | \240 &HF0   |
  375. | \033 &H21 !  | \085 &H55 U  | \137 &H89 â  | \189 &HBD Ω  | \241 &HF1 Ò  |
  376. | \034 &H22 "  | \086 &H56 V  | \138 &H8A ä  | \190 &HBE æ  | \242 &HF2 Ú  |
  377. | \035 &H23 #  | \087 &H57 W  | \139 &H8B ã  | \191 &HBF ø  | \243 &HF3 Û  |
  378. | \036 &H24 $  | \088 &H58 X  | \140 &H8C å  | \192 &HC0 ¿  | \244 &HF4 Ù  |
  379. | \037 &H25 %  | \089 &H59 Y  | \141 &H8D ç  | \193 &HC1 ¡  | \245 &HF5 ı  |
  380. | \038 &H26 &  | \090 &H5A Z  | \142 &H8E é  | \194 &HC2 ¬  | \246 &HF6 ˆ  |
  381. | \039 &H27 '  | \091 &H5B [  | \143 &H8F è  | \195 &HC3 √  | \247 &HF7 ˜  |
  382. | \040 &H28 (  | \092 &H5C \  | \144 &H90 ê  | \196 &HC4 ƒ  | \248 &HF8 ¯  |
  383. | \041 &H29 )  | \093 &H5D ]  | \145 &H91 ë  | \197 &HC5 ≈  | \249 &HF9 ˘  |
  384. | \042 &H2A *  | \094 &H5E ^  | \146 &H92 í  | \198 &HC6 Δ  | \250 &HFA ˙  |
  385. | \043 &H2B +  | \095 &H5F _  | \147 &H93 ì  | \199 &HC7 «  | \251 &HFB ˚  |
  386. | \044 &H2C ,  | \096 &H60 `  | \148 &H94 î  | \200 &HC8 »  | \252 &HFC ¸  |
  387. | \045 &H2D -  | \097 &H61 a  | \149 &H95 ï  | \201 &HC9 …  | \253 &HFD ˝  |
  388. | \046 &H2E .  | \098 &H62 b  | \150 &H96 ñ  | \202 &HCA    | \254 &HFE ˛  |
  389. | \047 &H2F /  | \099 &H63 c  | \151 &H97 ó  | \203 &HCB À  | \255 &HFF ˇ  |
  390. | \048 &H30 0  | \100 &H64 d  | \152 &H98 ò  | \204 &HCC Ã  |              |
  391. | \049 &H31 1  | \101 &H65 e  | \153 &H99 ô  | \205 &HCD Õ  |              |
  392. | \050 &H32 2  | \102 &H66 f  | \154 &H9A ö  | \206 &HCE Œ  |              |
  393. | \051 &H33 3  | \103 &H67 g  | \155 &H9B õ  | \207 &HCF œ  |              |
  394. +--------------+--------------+--------------+--------------+--------------+
  395.